define(["jquery","echart"], function ($,echarts) {

    getshichang = function () {
        option = {
            backgroundColor: '#404a59',
            title: {
                text: '平均时长',
                textStyle: {
                    color: '#fff'
                }
            },
            color: ['#3398DB'],
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis : [
                {
                    type : 'category',
                    data : ['直属大队', '海曙大队', '江北大队', '鄞州大队', '镇海大队', '北仑大队', '高新大队'],
                    axisTick: {
                        alignWithLabel: true
                    },
                    axisLabel: {
                        textStyle: {
                            color: '#ffffff'
                        }
                    },
                    axisLine:{
                        lineStyle:{
                            color:'#ffffff'
                        }
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value',
                    axisLabel: {
                        textStyle: {
                            color: '#ffffff'
                        }
                    },
                    axisLine:{
                        lineStyle:{
                            color:'#ffffff'
                        }
                    }
                }
            ],
            series : [
                {
                    name:'平均时长',
                    type:'bar',
                    barWidth: '60%',
                    data:[8, 9, 4, 2, 8, 9, 9]
                }
            ]
        };
        return option;
    }

    getjuli = function () {
        option = {
            backgroundColor: '#404a59',
            title: {
                text: '执法距离',
                subtext: '部门平均值',
                textStyle: {
                    color: '#fff'
                }
            },
            tooltip: {
                trigger: 'axis'
            },
            legend: {
                data:['最高气温']
            },
            toolbox: {
                show: false,
                feature: {
                    dataZoom: {
                        yAxisIndex: 'none'
                    },
                    dataView: {readOnly: false},
                    magicType: {type: ['line', 'bar']},
                    restore: {},
                    saveAsImage: {}
                }
            },
            xAxis:  {
                type: 'category',
                boundaryGap: false,
                data: ['直属大队', '海曙大队', '江北大队', '鄞州大队', '镇海大队', '北仑大队', '高新大队'],
                axisLabel: {
                    textStyle: {
                        color: '#ffffff'
                    }
                },
                axisLine:{
                    lineStyle:{
                        color:'#ffffff'
                    }
                }
            },
            yAxis: {
                type: 'value',
                axisLabel: {
                    formatter: '{value}千米',
                    color: '#ffffff'
                },
                axisLine:{
                    lineStyle:{
                        color:'#ffffff'
                    }
                }
            },
            series: [
                {
                    name:'执法距离',
                    type:'line',
                    data:[5, 6, 3, 4, 8, 9, 5],
                    markPoint: {
                        data: [
                            {type: 'max', name: '最大值'},
                            {type: 'min', name: '最小值'}
                        ]
                    },
                    markLine: {
                        data: [
                            {type: 'average', name: '平均值'}
                        ]
                    }
                }
            ]
        };
        return option
    }

    getxungeng = function () {

        var hours = ['直属大队', '海曙大队', '江北大队', '鄞州大队', '镇海大队', '北仑大队', '高新大队'];
        var days = ['星期六', '星期五', '星期四',
            '星期三', '星期二', '星期一', '星期天'];

        var data = [[0,0,0.5],[0,1,0.1],[0,2,0.1],[0,3,0.2],[0,4,0.1],[0,5,0.1],[0,6,0.3],
                    [1,0,0.7],[1,1,0.3],[1,2,0.2],[1,3,0.1],[1,4,0.0],[1,5,0.1],[1,6,0.0],
                    [2,0,0.1],[2,1,0.1],[2,2,0.0],[2,3,0.0],[2,4,0.0],[2,5,0.2],[2,6,0.0],
                    [3,0,0.7],[3,1,0.3],[3,2,0.2],[3,3,0.3],[3,4,0.3],[3,5,0.1],[3,6,0.1],
                    [4,0,0.1],[4,1,0.3],[4,2,0.2],[4,3,0.3],[4,4,0.4],[4,5,0.1],[4,6,0.5],
                    [5,0,0.2],[5,1,0.8],[5,2,0.3],[5,3,0.3],[5,4,0.3],[5,5,0.1],[5,6,0.1],
                    [6,0,0.1],[6,1,0.9],[6,2,0.5],[6,3,0.5],[6,4,0.2],[6,5,0.3],[6,6,0.1]];

        data = data.map(function (item) {
            return [item[1], item[0], item[2] || '-'];
        });

        option = {
            backgroundColor: '#404a59',
            tooltip: {
                position: 'top',
                formatter:function(pa){

                    return days[pa.value[1]]+" "+hours[pa.value[0]]+"</br>"+
                            pa.marker+"巡更指数: "+ pa.value[2];
                    //return  "巡更指数:" + pa.value[2]
                }
            },
            animation: false,
            grid: {
                height: '50%',
                y: '10%'
            },
            xAxis: {
                type: 'category',
                data: hours,
                splitArea: {
                    show: true
                },
                axisLine:{
                    lineStyle:{
                        color:'#ffffff'
                    }
                }
            },
            yAxis: {
                type: 'category',
                data: days,
                splitArea: {
                    show: true
                },
                axisLine:{
                    lineStyle:{
                        color:'#ffffff'
                    }
                }
            },
            visualMap: {
                min: 0,
                max: 1,
                calculable: true,
                orient: 'horizontal',
                left: 'center',
                bottom: '15%'
            },
            series: [{
                name: '巡更率',
                type: 'heatmap',
                data: data,
                label: {
                    normal: {
                        show: true
                    }
                },
                itemStyle: {
                    emphasis: {
                        shadowBlur: 10,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }]
        };
        return option;
    };

    
    return {
        getshichang : getshichang(),
        getjuli:getjuli(),
        getxungeng:getxungeng()
    }

});